package com.test.sort;

public class DirectSelSort {

	public static void main(String[] args) {
		int arrLen = (int) Math.round(Math.random() * 10);
		int[] arr = new int[arrLen];
		for (int i = 0; i < arrLen; i++) {
			arr[i] = (int) Math.round(Math.random() * 10);
		}
		for (int i = 0; i < arrLen; i++) {
			System.out.print(arr[i] + ",");
		}

		System.out.println();

		int sortedIndex = 0;
		for (int i = sortedIndex; i < arrLen; i++) {
			for (int j = 0; j < sortedIndex; j++) {
				if (arr[j] <= arr[i] && arr[j + 1] >= arr[i]) {
					for (int k = i; k > j; k--) {
						int temp = arr[k];
						arr[k] = arr[k-1];
						arr[k-1] = temp;
					}
				}
			}
		}
		

		for (int i = 0; i < arrLen; i++) {
			System.out.print(arr[i] + ",");
		}
	}
}
